package com.me.components {
	import com.me.FileLoader;

	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filesystem.File;
	import flash.geom.Point;
	import flash.text.TextField;

	/**
	 *
	 * @author yw
	 *
	 * @Date 2011-9-16 下午03:48:48
	 */
	public class BitImage extends MapResource {
		public var imgData:BitmapData;

		public function BitImage(file:File, handler:Function) {
			super();
			_fileName = file.name;
			_loadCompleteHandler = handler;
			FileLoader.getInstance().loadFile(file, fileLoaded);
		}

		private function fileLoaded(data:Bitmap):void {
			try {
				width = data.width;
				height = data.height;
				imgData = new BitmapData(data.width, data.height);
				imgData.copyPixels(data.bitmapData, data.bitmapData.rect, new Point(0, 0));
				addChild(new Bitmap(imgData));
				_loadCompleteHandler(this);
			} catch (e:Error) {

			}
		}
	}
}
